<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<%@ include file="../header.jsp"%>
</head>
<body>
	<div id="divId">hdf</div>
	<input type="button" value="AjaxGet" onclick="ajaxGet()"><br/>
	<input type="button" value="AjaxPost" onclick="ajaxPost()">
	<script type="text/javascript">
		function ajaxGet() {
			// $.get(url, [data], [callback], [type])
			$.get(
				'${pageContext.request.contextPath}/ajax',
				{'name': 'zhanggan'},
				function(data) {
					console.log(data);
					$('#divId').html(data.gender);
				},
				'json'
			);
		}
		
		function ajaxPost() {
			// $.get(url, [data], [callback], [type])
			$.post(
				'${pageContext.request.contextPath}/ajax',
				{'name': 'lisi'},
				function(data) {
					console.log(data);
					$('#divId').html(data.gender);
				},
				'json'
			);
		}
	</script>
</body>
</html>